﻿//********************************************************************************//
//创建日期：<创建日期，2016-05-11>
//创建作者：<郭登杰>
//功能说明：来函流程公共控件-右侧下方审批意见与审批量区域
//********************************************************************************//

using System;
using System.Data;
using System.Web.UI;
using BLL;
using BLL.Access;
using DevExpress.Web;
using Entity;
using Web.Class;

namespace Web.Controls.LAIHAN
{
    public partial class UCLHLCSHENPI : UserControl, IUCLHOperate
    {
        #region 属性

        /// <summary>
        ///     来函类型
        /// </summary>
        public eLaiHanLX LaiHanLX { get; set; }

        /// <summary>
        ///     来函流程
        /// </summary>
        public eLaiHanLCBH LaiHanLC { get; set; }

        public string HuJiSPYJ => txtHuJiSPYJ.Text;

        /// <summary>
        ///     当前步骤年度调整审批详情
        /// </summary>
        public YS_LH_NIANTIAOZ NianDuTZSPXQ { get; set; }

        /// <summary>
        ///     当前来函信息年
        /// </summary>
        private int Y
        {
            get { return ViewState["Y"] == null ? -1 : Convert.ToInt32(ViewState["Y"]); }
            set { ViewState["Y"] = value; }
        }

        #endregion

        #region 变量

        /// <summary>
        ///     数据库操作
        /// </summary>
        private readonly SpHelper _sphelper = new SpHelper();


        /// <summary>
        ///     月调整BLL
        /// </summary>
        private readonly YS_LH_YUETIAOZProcess _YS_LH_YUETIAOZBLL = new YS_LH_YUETIAOZProcess();

        /// <summary>
        ///     年度调整BLL
        /// </summary>
        private readonly YS_LH_NIANTIAOZBLL _YS_LH_NIANTIAOZBLL = new YS_LH_NIANTIAOZBLL();

        /// <summary>
        ///     基建调整BLL
        /// </summary>
        private readonly YS_LH_JIJIANTZBLL _YS_LH_JIJIANTZBLL = new YS_LH_JIJIANTZBLL();

        /// <summary>
        ///     计划变更BLL
        /// </summary>
        private readonly YS_LH_JIHUABGBLL _YS_LH_JIHUABGBLL = new YS_LH_JIHUABGBLL();

        /// <summary>
        ///     表计因素BLL
        /// </summary>
        private readonly YS_LH_BIAOJIYSZXProcess _YS_LH_BIAOJIYSZXProcess = new YS_LH_BIAOJIYSZXProcess();

        /// <summary>
        ///     计划指标BLL
        /// </summary>
        private readonly YS_LH_JIHUAZBZXProcess _YS_LH_JIHUAZBZXProcess = new YS_LH_JIHUAZBZXProcess();

        /// <summary>
        ///     并户BLL
        /// </summary>
        private readonly YS_LH_BINGHUBLL _YS_LH_BINGHUBLL = new YS_LH_BINGHUBLL();

        /// <summary>
        ///     销户BLL
        /// </summary>
        private readonly YS_LH_XIAOHUBLL _YS_LH_XIAOHUBLL = new YS_LH_XIAOHUBLL();

        /// <summary>
        ///     销表BLL
        /// </summary>
        private readonly YS_LH_XIAOBIAOBLL _YS_LH_XIAOBIAOBLL = new YS_LH_XIAOBIAOBLL();

        /// <summary>
        ///     退款BLL
        /// </summary>
        private readonly YS_LH_TUIKUANBLL _YS_LH_TUIKUANBLL = new YS_LH_TUIKUANBLL();

        /// <summary>
        ///     改户BLL
        /// </summary>
        private readonly YS_LH_GAIHUXXBLL _YS_LH_GAIHUXXBLL = new YS_LH_GAIHUXXBLL();

        /// <summary>
        ///     水资源并户BLL
        /// </summary>
        private QS_LH_BINGHUBLL _QS_LH_BINGHUBLL = new QS_LH_BINGHUBLL();

        #endregion

        #region 事件

        /// <summary>
        ///     页面加载事件
        /// </summary>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack) InitControl();
        }

        /// <summary>
        ///     响应前台回调
        /// </summary>
        protected void ASPxCallback1_Callback(object source, CallbackEventArgs e)
        {
            var cr = new CallbackResult(e.Parameter);
        }

        #endregion

        #region 方法

        /// <summary>
        ///     配置控件
        /// </summary>
        public void InitControl()
        {
            if (LaiHanLC == eLaiHanLCBH.业务员)
            {
                txtYiJian.Height = 90;
                txtJHBGSPYJ.Height = 90;
                txtHuJiSPYJ.Height = 90;
            }
            else
            {
                txtYiJian.Height = 18;
                txtJHBGSPYJ.Height = 18;
                txtHuJiSPYJ.Height = 18;
            }

            if (LaiHanLC == eLaiHanLCBH.业务员)
            {
                lblJianYiLTip.Text = "承办人建议量：";
                lblJianYiLTipPre.Text = "承办人";
                lblJianYiLTipSfxx.Text = "建议量";
                lblJHBGSPLTip.Text = "承办人建议量：";
                lblJianYiTip.Text = "承办人意见：";
                lblJHBGSPYJTip.Text = "承办人意见：";
                lblHuJiSPYJTip.Text = "承办人意见：";
            }
            else if (LaiHanLC == eLaiHanLCBH.主任)
            {
                lblJianYiLTip.Text = "主任复核量：";
                lblJianYiLTipPre.Text = "主任";
                lblJianYiLTipSfxx.Text = "复核量";
                lblJHBGSPLTip.Text = "主任复核量：";
                lblJianYiTip.Text = "主任意见：";
                lblJHBGSPYJTip.Text = "主任意见：";
                lblHuJiSPYJTip.Text = BusinessTool.WType == 0 ? "主任意见：" : "取水科长意见:";
            }
            else if (LaiHanLC == eLaiHanLCBH.节水科)
            {
                lblJianYiLTip.Text = "节水科审核量：";
                lblJianYiLTipPre.Text = "节水科";
                lblJianYiLTipSfxx.Text = "审核量";
                lblJHBGSPLTip.Text = "节水科审核量：";
                lblJianYiTip.Text = "节水科意见：";
                lblJHBGSPYJTip.Text = "节水科意见：";
                lblHuJiSPYJTip.Text = "节水科意见：";
            }
            else if (LaiHanLC == eLaiHanLCBH.计财科)
            {
                lblJianYiLTip.Text = "计财科复审量：";
                lblJianYiLTipPre.Text = "计财科";
                lblJianYiLTipSfxx.Text = "复审量";
                lblJHBGSPLTip.Text = "计财科复审量：";
                lblJianYiTip.Text = "计财科意见：";
                lblJHBGSPYJTip.Text = "计财科意见：";
                lblHuJiSPYJTip.Text = "计财科意见：";
            }
            else if (LaiHanLC == eLaiHanLCBH.处长)
            {
                lblJianYiLTip.Text = "处长审批量：";
                lblJianYiLTipPre.Text = "处长";
                lblJianYiLTipSfxx.Text = "审批量";
                lblJHBGSPLTip.Text = "处长审批量：";
                lblJianYiTip.Text = "处长意见：";
                lblJHBGSPYJTip.Text = "处长意见：";
                lblHuJiSPYJTip.Text = "处长意见：";
            }

            //根据来函类型控件显隐
            switch (LaiHanLX)
            {
                case eLaiHanLX.年度:
                    tabYM.Visible = true;
                    tabJHBG.Visible = false;
                    tabHuJi.Visible = false;
                    trSingleY.Visible = true;
                    trBN.Visible = false;
                    trXN.Visible = false;
                    break;
                case eLaiHanLX.基建调整:
                    tabYM.Visible = true;
                    tabJHBG.Visible = false;
                    tabHuJi.Visible = false;
                    trSingleY.Visible = false;
                    trBN.Visible = true;
                    trXN.Visible = true;
                    break;
                case eLaiHanLX.月度:
                    tabYM.Visible = false;
                    tabJHBG.Visible = true;
                    tabHuJi.Visible = false;
                    break;
                case eLaiHanLX.计划变更:
                    tabYM.Visible = false;
                    tabJHBG.Visible = true;
                    tabHuJi.Visible = false;
                    break;
                case eLaiHanLX.表计因素注销:
                    tabYM.Visible = false;
                    tabJHBG.Visible = true;
                    tabHuJi.Visible = false;
                    break;
                case eLaiHanLX.计划指标注销:
                    tabYM.Visible = false;
                    tabJHBG.Visible = true;
                    tabHuJi.Visible = false;
                    lblJHBGSPLTip.Visible = false;
                    txtJHBGSPL.Visible = false;
                    break;
                case eLaiHanLX.并户:
                    tabYM.Visible = false;
                    tabJHBG.Visible = false;
                    tabHuJi.Visible = true;
                    //流程在业务员之前不显示审批操作,并默认操作结果为通过
                    trHuJiSPJG.Visible = (int) LaiHanLC > (int) eLaiHanLCBH.业务员;
                    break;
                case eLaiHanLX.分户:
                    tabYM.Visible = false;
                    tabJHBG.Visible = false;
                    tabHuJi.Visible = true;
                    //流程在业务员之前不显示审批操作,并默认操作结果为通过
                    trHuJiSPJG.Visible = (int) LaiHanLC > (int) eLaiHanLCBH.业务员;
                    break;
                case eLaiHanLX.销户:
                    tabYM.Visible = false;
                    tabJHBG.Visible = false;
                    tabHuJi.Visible = true;
                    //流程在业务员之前不显示审批操作,并默认操作结果为通过
                    trHuJiSPJG.Visible = (int) LaiHanLC > (int) eLaiHanLCBH.业务员;
                    break;
                case eLaiHanLX.销表:
                    tabYM.Visible = false;
                    tabJHBG.Visible = false;
                    tabHuJi.Visible = true;
                    //流程在业务员之前不显示审批操作,并默认操作结果为通过
                    trHuJiSPJG.Visible = (int) LaiHanLC > (int) eLaiHanLCBH.业务员;
                    break;
                case eLaiHanLX.退款:
                    tabYM.Visible = false;
                    tabJHBG.Visible = false;
                    tabHuJi.Visible = true;
                    //流程在业务员之前不显示审批操作,并默认操作结果为通过
                    trHuJiSPJG.Visible = (int) LaiHanLC > (int) eLaiHanLCBH.业务员;
                    break;
                case eLaiHanLX.改户:
                    tabYM.Visible = false;
                    tabJHBG.Visible = false;
                    tabHuJi.Visible = true;
                    //流程在业务员之前不显示审批操作,并默认操作结果为通过
                    trHuJiSPJG.Visible = (int) LaiHanLC > (int) eLaiHanLCBH.业务员;
                    break;
                case eLaiHanLX.水资源表过户:
                    tabYM.Visible = false;
                    tabJHBG.Visible = false;
                    tabHuJi.Visible = true;
                    //流程在业务员之前不显示审批操作,并默认操作结果为通过
                    trHuJiSPJG.Visible = (int) LaiHanLC > (int) eLaiHanLCBH.业务员;
                    break;
                case eLaiHanLX.水资源并户:
                    tabYM.Visible = false;
                    tabJHBG.Visible = false;
                    tabHuJi.Visible = true;
                    //流程在业务员之前不显示审批操作,并默认操作结果为通过
                    trHuJiSPJG.Visible = (int) LaiHanLC > (int) eLaiHanLCBH.业务员;
                    break;
                case eLaiHanLX.水资源采灌计划:
                    tabYM.Visible = false;
                    tabJHBG.Visible = false;
                    tabHuJi.Visible = true;
                    //流程在业务员之前不显示审批操作,并默认操作结果为通过
                    trHuJiSPJG.Visible = (int) LaiHanLC > (int) eLaiHanLCBH.业务员;
                    break;
                case eLaiHanLX.水资源分户:
                    tabYM.Visible = false;
                    tabJHBG.Visible = false;
                    tabHuJi.Visible = true;
                    //流程在业务员之前不显示审批操作,并默认操作结果为通过
                    trHuJiSPJG.Visible = (int) LaiHanLC > (int) eLaiHanLCBH.业务员;
                    break;
                case eLaiHanLX.水资源加价水量调整:
                    tabYM.Visible = false;
                    tabJHBG.Visible = false;
                    tabHuJi.Visible = true;
                    //流程在业务员之前不显示审批操作,并默认操作结果为通过
                    trHuJiSPJG.Visible = (int) LaiHanLC > (int) eLaiHanLCBH.业务员;
                    break;
                case eLaiHanLX.水资源井过户:
                    tabYM.Visible = false;
                    tabJHBG.Visible = false;
                    tabHuJi.Visible = true;
                    //流程在业务员之前不显示审批操作,并默认操作结果为通过
                    trHuJiSPJG.Visible = (int) LaiHanLC > (int) eLaiHanLCBH.业务员;
                    break;
                case eLaiHanLX.水资源井性质修改:
                    tabYM.Visible = false;
                    tabJHBG.Visible = false;
                    tabHuJi.Visible = true;
                    //流程在业务员之前不显示审批操作,并默认操作结果为通过
                    trHuJiSPJG.Visible = (int) LaiHanLC > (int) eLaiHanLCBH.业务员;
                    break;
                case eLaiHanLX.水资源开采计划:
                    tabYM.Visible = false;
                    tabJHBG.Visible = false;
                    tabHuJi.Visible = true;
                    //流程在业务员之前不显示审批操作,并默认操作结果为通过
                    trHuJiSPJG.Visible = (int) LaiHanLC > (int) eLaiHanLCBH.业务员;
                    break;
                case eLaiHanLX.水资源深井类型修改:
                    tabYM.Visible = false;
                    tabJHBG.Visible = false;
                    tabHuJi.Visible = true;
                    //流程在业务员之前不显示审批操作,并默认操作结果为通过
                    trHuJiSPJG.Visible = (int) LaiHanLC > (int) eLaiHanLCBH.业务员;
                    break;
                case eLaiHanLX.水资源退款:
                    tabYM.Visible = false;
                    tabJHBG.Visible = false;
                    tabHuJi.Visible = true;
                    //流程在业务员之前不显示审批操作,并默认操作结果为通过
                    trHuJiSPJG.Visible = (int) LaiHanLC > (int) eLaiHanLCBH.业务员;
                    break;
                case eLaiHanLX.水资源销表:
                    tabYM.Visible = false;
                    tabJHBG.Visible = false;
                    tabHuJi.Visible = true;
                    //流程在业务员之前不显示审批操作,并默认操作结果为通过
                    trHuJiSPJG.Visible = (int) LaiHanLC > (int) eLaiHanLCBH.业务员;
                    break;
                case eLaiHanLX.水资源销户:
                    tabYM.Visible = false;
                    tabJHBG.Visible = false;
                    tabHuJi.Visible = true;
                    //流程在业务员之前不显示审批操作,并默认操作结果为通过
                    trHuJiSPJG.Visible = (int) LaiHanLC > (int) eLaiHanLCBH.业务员;
                    break;
                case eLaiHanLX.水资源销井:
                    tabYM.Visible = false;
                    tabJHBG.Visible = false;
                    tabHuJi.Visible = true;
                    //流程在业务员之前不显示审批操作,并默认操作结果为通过
                    trHuJiSPJG.Visible = (int) LaiHanLC > (int) eLaiHanLCBH.业务员;
                    break;
                case eLaiHanLX.水资源注销井恢复:
                    tabYM.Visible = false;
                    tabJHBG.Visible = false;
                    tabHuJi.Visible = true;
                    //流程在业务员之前不显示审批操作,并默认操作结果为通过
                    trHuJiSPJG.Visible = (int) LaiHanLC > (int) eLaiHanLCBH.业务员;
                    break;
                case eLaiHanLX.水资源销取水口:
                    tabYM.Visible = false;
                    tabJHBG.Visible = false;
                    tabHuJi.Visible = true;
                    //流程在业务员之前不显示审批操作,并默认操作结果为通过
                    trHuJiSPJG.Visible = (int) LaiHanLC > (int) eLaiHanLCBH.业务员;
                    break;
                case eLaiHanLX.水资源取水口过户:
                    tabYM.Visible = false;
                    tabJHBG.Visible = false;
                    tabHuJi.Visible = true;
                    //流程在业务员之前不显示审批操作,并默认操作结果为通过
                    trHuJiSPJG.Visible = (int) LaiHanLC > (int) eLaiHanLCBH.业务员;
                    break;
                default:
                    break;
            }
        }

        /// <summary>
        ///     提交验证
        /// </summary>
        public ValidateRS Validate()
        {
            var rs = new ValidateRS();
            if (LaiHanLX == eLaiHanLX.年度)
            {
                if (txtSplM1.Text == "" || txtSplM2.Text == "" || txtSplM3.Text == "" || txtSplM4.Text == "" ||
                    txtSplM5.Text == ""
                    || txtSplM6.Text == "" || txtSplM7.Text == "" || txtSplM8.Text == "" || txtSplM9.Text == "" ||
                    txtSplM10.Text == ""
                    || txtSplM11.Text == "" || txtSplM12.Text == "")
                {
                    rs.Msg = "请将计划量输入完整。";
                    return rs;
                }

                if (txtYiJian.Text.Trim() == "")
                {
                    rs.Msg = "请输入意见。";
                    return rs;
                }
            }
            else if (LaiHanLX == eLaiHanLX.基建调整)
            {
                if (
                    txtBNM1.Text == "" || txtBNM2.Text == "" || txtBNM3.Text == "" || txtBNM4.Text == "" ||
                    txtBNM5.Text == ""
                    || txtBNM6.Text == "" || txtBNM7.Text == "" || txtBNM8.Text == "" || txtBNM9.Text == "" ||
                    txtBNM10.Text == ""
                    || txtBNM11.Text == "" || txtBNM12.Text == "" || txtXNM1.Text == "" || txtXNM2.Text == "" ||
                    txtXNM3.Text == "" || txtXNM4.Text == "" || txtXNM5.Text == ""
                    || txtXNM6.Text == "" || txtXNM7.Text == "" || txtXNM8.Text == "" || txtXNM9.Text == "" ||
                    txtXNM10.Text == ""
                    || txtXNM11.Text == "" || txtXNM12.Text == ""
                )
                {
                    rs.Msg = "请将计划量输入完整。";
                    return rs;
                }

                if (txtYiJian.Text.Trim() == "")
                {
                    rs.Msg = "请输入意见。";
                    return rs;
                }
            }
            else if (LaiHanLX == eLaiHanLX.计划变更 || LaiHanLX == eLaiHanLX.表计因素注销 || LaiHanLX == eLaiHanLX.月度)
            {
                if (txtJHBGSPL.Text.Trim() == "")
                {
                    rs.Msg = "请输入意见量。";
                    return rs;
                }

                if (txtJHBGSPYJ.Text.Trim() == "")
                {
                    rs.Msg = "请输入意见。";
                    return rs;
                }
            }
            else if (LaiHanLX == eLaiHanLX.计划指标注销)
            {
                if (txtJHBGSPYJ.Text.Trim() == "")
                {
                    rs.Msg = "请输入意见。";
                    return rs;
                }
            }
            else if (LaiHanLX == eLaiHanLX.改户 || LaiHanLX == eLaiHanLX.分户 || LaiHanLX == eLaiHanLX.并户 ||
                     LaiHanLX == eLaiHanLX.销户 || LaiHanLX == eLaiHanLX.销表 || LaiHanLX == eLaiHanLX.退款
                     || (int) LaiHanLX >= 20)
            {
                if (trHuJiSPJG.Visible && !cbBuTongY.Checked && !cbTongYi.Checked)
                {
                    rs.Msg = "请选择审批操作。";
                    return rs;
                }

                if (txtHuJiSPYJ.Text.Trim() == "")
                {
                    rs.Msg = "请输入意见。";
                    return rs;
                }
            }

            rs.IsSuccess = true;
            return rs;
        }


        /// <summary>
        ///     清除数据
        /// </summary>
        public void ClearInfo()
        {
            txtSplM1.Text = "";
            txtSplM2.Text = "";
            txtSplM3.Text = "";
            txtSplM4.Text = "";
            txtSplM5.Text = "";
            txtSplM6.Text = "";
            txtSplM7.Text = "";
            txtSplM8.Text = "";
            txtSplM9.Text = "";
            txtSplM10.Text = "";
            txtSplM11.Text = "";
            txtSplM12.Text = "";
            txtSplMSUM.Text = "";
            txtBNM1.Text = "";
            txtBNM2.Text = "";
            txtBNM3.Text = "";
            txtBNM4.Text = "";
            txtBNM5.Text = "";
            txtBNM6.Text = "";
            txtBNM7.Text = "";
            txtBNM8.Text = "";
            txtBNM9.Text = "";
            txtBNM10.Text = "";
            txtBNM11.Text = "";
            txtBNM12.Text = "";
            txtBNMSUM.Text = "";
            txtXNM1.Text = "";
            txtXNM2.Text = "";
            txtXNM3.Text = "";
            txtXNM4.Text = "";
            txtXNM5.Text = "";
            txtXNM6.Text = "";
            txtXNM7.Text = "";
            txtXNM8.Text = "";
            txtXNM9.Text = "";
            txtXNM10.Text = "";
            txtXNM11.Text = "";
            txtXNM12.Text = "";
            txtXNMSUM.Text = "";
            txtYiJian.Text = "";
            txtJHBGSPL.Text = "";
            txtJHBGSPYJ.Text = "";
            cbBuTongY.Checked = false;
            cbTongYi.Checked = false;
            txtHuJiSPYJ.Text = "";
        }

        /// <summary>
        ///     加载对应审批内容(当前或上一步的)
        /// </summary>
        /// <param name="drc">结果集</param>
        /// <returns>true:确认未提交,存在当前流程的审批意见 false:一般情况,只有前一流程的审批</returns>
        private bool LoadShenPiContent(DataRowCollection drc)
        {
            if (drc.Count == 0) return false;
            if (LaiHanLX == eLaiHanLX.月度)
            {
                // 各级的水量
                Func<string> FGet业务员 = () =>
                {
                    if (Convert.IsDBNull(drc[0]["I_YEWUYJY"]))
                    {
                        int I_SHENQINGL = 0;
                        try
                        {
                            I_SHENQINGL = Convert.ToInt32(drc[0]["I_SHENQINGL"]);
                            I_SHENQINGL = (int)(Math.Ceiling(I_SHENQINGL / 100.0) * 100);
                        }
                        catch (Exception) { }
                        return I_SHENQINGL.ToString();
                    }
                    return Convert.ToString(drc[0]["I_YEWUYJY"]);
                };
                Func<string> FGet主任 = () =>
                {
                    if (Convert.IsDBNull(drc[0]["I_ZHUREN"])) return FGet业务员();
                    return Convert.ToString(drc[0]["I_ZHUREN"]);
                };
                Func<string> FGet节水科 = () =>
                {
                    if (Convert.IsDBNull(drc[0]["I_JIESHUIKZ"])) return FGet主任();
                    return Convert.ToString(drc[0]["I_JIESHUIKZ"]);
                };
                Func<string> FGet计财科 = () =>
                {
                    if (Convert.IsDBNull(drc[0]["I_JICAIKZ"])) return FGet节水科();
                    return Convert.ToString(drc[0]["I_JICAIKZ"]);
                };
                Func<string> FGet处长 = () =>
                {
                    if (Convert.IsDBNull(drc[0]["I_CHUZHANG"])) return FGet计财科();
                    return Convert.ToString(drc[0]["I_CHUZHANG"]);
                };
                if (LaiHanLC == eLaiHanLCBH.业务员)
                {
                    //txtJHBGSPL.Text = Convert.ToString(drc[0]["I_YEWUYJY"]);
                    txtJHBGSPL.Text = FGet业务员();
                    txtJHBGSPYJ.Text = Convert.ToString(drc[0]["S_YEWUYJY"]);
                }
                else if (LaiHanLC == eLaiHanLCBH.主任)
                {
                    //txtJHBGSPL.Text = !Convert.IsDBNull(drc[0]["I_ZHUREN"])
                    //    ? Convert.ToString(drc[0]["I_ZHUREN"])
                    //    : Convert.ToString(drc[0]["I_YEWUYJY"]);
                    txtJHBGSPL.Text = FGet主任();
                    txtJHBGSPYJ.Text = Convert.ToString(drc[0]["S_ZHUREN"]);
                }
                else if (LaiHanLC == eLaiHanLCBH.节水科)
                {
                    //if (Convert.IsDBNull(drc[0]["I_JIESHUIKZ"]))
                    //{
                    //    txtJHBGSPL.Text = !Convert.IsDBNull(drc[0]["I_JIESHUIKZ"])
                    //        ? Convert.ToString(drc[0]["I_JIESHUIKZ"])
                    //        : (!Convert.IsDBNull(drc[0]["I_ZHUREN"])
                    //            ? Convert.ToString(drc[0]["I_ZHUREN"])
                    //            : Convert.ToString(drc[0]["I_YEWUYJY"]));
                    //}
                    //else if (Convert.ToInt32(drc[0]["I_JIESHUIKZ"]) == 0)
                    //{
                    //    txtJHBGSPL.Text = !Convert.IsDBNull(drc[0]["I_ZHUREN"])
                    //        ? Convert.ToString(drc[0]["I_ZHUREN"])
                    //        : Convert.ToString(drc[0]["I_YEWUYJY"]);
                    //}
                    txtJHBGSPL.Text = FGet节水科();
                    txtJHBGSPYJ.Text = Convert.ToString(drc[0]["S_JIESHUIKZ"]);
                }
                else if (LaiHanLC == eLaiHanLCBH.计财科)
                {
                    //txtJHBGSPL.Text = !Convert.IsDBNull(drc[0]["I_JICAIKZ"])
                    //    ? Convert.ToString(drc[0]["I_JICAIKZ"])
                    //    : Convert.ToString(drc[0]["I_JIESHUIKZ"]);
                    txtJHBGSPL.Text = FGet计财科();
                    txtJHBGSPYJ.Text = Convert.ToString(drc[0]["S_JICAIKZ"]);
                }
                else if (LaiHanLC == eLaiHanLCBH.处长)
                {
                    //txtJHBGSPL.Text = !Convert.IsDBNull(drc[0]["I_CHUZHANG"])
                    //    ? Convert.ToString(drc[0]["I_CHUZHANG"])
                    //    : Convert.ToString(drc[0]["I_JICAIKZ"]);
                    txtJHBGSPL.Text = FGet处长();
                    txtJHBGSPYJ.Text = Convert.ToString(drc[0]["S_CHUZHANG"]);
                }

                //if (txtJHBGSPL.Text != "" && txtJHBGSPYJ.Text != "") return true;
                //txtJHBGSPYJ.Text = LaiHanLC == eLaiHanLCBH.主任 || LaiHanLC == eLaiHanLCBH.节水科 ? "拟同意。" :
                //    LaiHanLC == eLaiHanLCBH.计财科 && Convert.ToInt32(drc[0]["I_SHENQINGL"]) > 1000 ? "拟同意。" :
                //    LaiHanLC == eLaiHanLCBH.计财科 && Convert.ToInt32(drc[0]["I_SHENQINGL"]) <= 1000 ||
                //    LaiHanLC == eLaiHanLCBH.处长 ? "同意。" :
                //    "";

                if (!string.IsNullOrEmpty(txtJHBGSPL.Text) && !string.IsNullOrEmpty(txtJHBGSPYJ.Text))
                    return true;
                if (eLaiHanLCBH.业务员 != LaiHanLC)
                    txtJHBGSPYJ.Text = LaiHanLC == eLaiHanLCBH.处长
                        || (LaiHanLC == eLaiHanLCBH.计财科 && Convert.ToInt32(drc[0]["I_SHENQINGL"]) <= 1000)
                        ?  "同意。" : "拟同意。";

                return false;
            }

            var isNowFlow = true;
            var rowIndexs = LaiHanLCTools.GetNeedRowIndexs(drc, (int) LaiHanLX, LaiHanLC);
            //无当前步骤
            if (rowIndexs.Count == 0)
            {
                isNowFlow = false;
                //获取上一步骤
                var preFlow = LaiHanLCTools.GetPreFlow((int) LaiHanLX, (int) LaiHanLC);
                rowIndexs = LaiHanLCTools.GetNeedRowIndexs(drc, (int) LaiHanLX, preFlow);
                //为本部用户时,跳过了主任,继续向前获取
                if (rowIndexs.Count == 0)
                {
                    preFlow = LaiHanLCTools.GetPreFlow((int) LaiHanLX, (int) preFlow);
                    rowIndexs = LaiHanLCTools.GetNeedRowIndexs(drc, (int) LaiHanLX, preFlow);
                }
            }

            if (LaiHanLX == eLaiHanLX.年度)
            {
                txtSplM1.Text = Convert.ToString(drc[rowIndexs[0]]["I_M1"]);
                txtSplM2.Text = Convert.ToString(drc[rowIndexs[0]]["I_M2"]);
                txtSplM3.Text = Convert.ToString(drc[rowIndexs[0]]["I_M3"]);
                txtSplM4.Text = Convert.ToString(drc[rowIndexs[0]]["I_M4"]);
                txtSplM5.Text = Convert.ToString(drc[rowIndexs[0]]["I_M5"]);
                txtSplM6.Text = Convert.ToString(drc[rowIndexs[0]]["I_M6"]);
                txtSplM7.Text = Convert.ToString(drc[rowIndexs[0]]["I_M7"]);
                txtSplM8.Text = Convert.ToString(drc[rowIndexs[0]]["I_M8"]);
                txtSplM9.Text = Convert.ToString(drc[rowIndexs[0]]["I_M9"]);
                txtSplM10.Text = Convert.ToString(drc[rowIndexs[0]]["I_M10"]);
                txtSplM11.Text = Convert.ToString(drc[rowIndexs[0]]["I_M11"]);
                txtSplM12.Text = Convert.ToString(drc[rowIndexs[0]]["I_M12"]);
                txtSplMSUM.Text = (Convert.ToInt32(txtSplM1.Text) + Convert.ToInt32(txtSplM2.Text) +
                                   Convert.ToInt32(txtSplM3.Text)
                                   + Convert.ToInt32(txtSplM4.Text) + Convert.ToInt32(txtSplM5.Text) +
                                   Convert.ToInt32(txtSplM6.Text)
                                   + Convert.ToInt32(txtSplM7.Text) + Convert.ToInt32(txtSplM8.Text) +
                                   Convert.ToInt32(txtSplM9.Text)
                                   + Convert.ToInt32(txtSplM10.Text) + Convert.ToInt32(txtSplM11.Text) +
                                   Convert.ToInt32(txtSplM12.Text)).ToString();
                if (isNowFlow) txtYiJian.Text = Convert.ToString(drc[rowIndexs[0]]["S_SHENPIYJ"]);
            }
            else if (LaiHanLX == eLaiHanLX.基建调整)
            {
                //本年
                txtBNM1.Text = Convert.ToString(drc[rowIndexs[0]]["I_M1"]);
                txtBNM2.Text = Convert.ToString(drc[rowIndexs[0]]["I_M2"]);
                txtBNM3.Text = Convert.ToString(drc[rowIndexs[0]]["I_M3"]);
                txtBNM4.Text = Convert.ToString(drc[rowIndexs[0]]["I_M4"]);
                txtBNM5.Text = Convert.ToString(drc[rowIndexs[0]]["I_M5"]);
                txtBNM6.Text = Convert.ToString(drc[rowIndexs[0]]["I_M6"]);
                txtBNM7.Text = Convert.ToString(drc[rowIndexs[0]]["I_M7"]);
                txtBNM8.Text = Convert.ToString(drc[rowIndexs[0]]["I_M8"]);
                txtBNM9.Text = Convert.ToString(drc[rowIndexs[0]]["I_M9"]);
                txtBNM10.Text = Convert.ToString(drc[rowIndexs[0]]["I_M10"]);
                txtBNM11.Text = Convert.ToString(drc[rowIndexs[0]]["I_M11"]);
                txtBNM12.Text = Convert.ToString(drc[rowIndexs[0]]["I_M12"]);
                txtBNMSUM.Text = (Convert.ToInt32(txtBNM1.Text) + Convert.ToInt32(txtBNM2.Text) +
                                  Convert.ToInt32(txtBNM3.Text)
                                  + Convert.ToInt32(txtBNM4.Text) + Convert.ToInt32(txtBNM5.Text) +
                                  Convert.ToInt32(txtBNM6.Text)
                                  + Convert.ToInt32(txtBNM7.Text) + Convert.ToInt32(txtBNM8.Text) +
                                  Convert.ToInt32(txtBNM9.Text)
                                  + Convert.ToInt32(txtBNM10.Text) + Convert.ToInt32(txtBNM11.Text) +
                                  Convert.ToInt32(txtBNM12.Text)).ToString();
                if (isNowFlow) txtYiJian.Text = Convert.ToString(drc[rowIndexs[0]]["S_SHENPIYJ"]);
                //下年
                txtXNM1.Text = Convert.ToString(drc[rowIndexs[1]]["I_M1"]);
                txtXNM2.Text = Convert.ToString(drc[rowIndexs[1]]["I_M2"]);
                txtXNM3.Text = Convert.ToString(drc[rowIndexs[1]]["I_M3"]);
                txtXNM4.Text = Convert.ToString(drc[rowIndexs[1]]["I_M4"]);
                txtXNM5.Text = Convert.ToString(drc[rowIndexs[1]]["I_M5"]);
                txtXNM6.Text = Convert.ToString(drc[rowIndexs[1]]["I_M6"]);
                txtXNM7.Text = Convert.ToString(drc[rowIndexs[1]]["I_M7"]);
                txtXNM8.Text = Convert.ToString(drc[rowIndexs[1]]["I_M8"]);
                txtXNM9.Text = Convert.ToString(drc[rowIndexs[1]]["I_M9"]);
                txtXNM10.Text = Convert.ToString(drc[rowIndexs[1]]["I_M10"]);
                txtXNM11.Text = Convert.ToString(drc[rowIndexs[1]]["I_M11"]);
                txtXNM12.Text = Convert.ToString(drc[rowIndexs[1]]["I_M12"]);
                txtXNMSUM.Text = (Convert.ToInt32(txtXNM1.Text) + Convert.ToInt32(txtXNM2.Text) +
                                  Convert.ToInt32(txtXNM3.Text)
                                  + Convert.ToInt32(txtXNM4.Text) + Convert.ToInt32(txtXNM5.Text) +
                                  Convert.ToInt32(txtXNM6.Text)
                                  + Convert.ToInt32(txtXNM7.Text) + Convert.ToInt32(txtXNM8.Text) +
                                  Convert.ToInt32(txtXNM9.Text)
                                  + Convert.ToInt32(txtXNM10.Text) + Convert.ToInt32(txtXNM11.Text) +
                                  Convert.ToInt32(txtXNM12.Text)).ToString();
            }
            else if (LaiHanLX == eLaiHanLX.计划变更 || LaiHanLX == eLaiHanLX.表计因素注销)
            {
                txtJHBGSPL.Text = Convert.ToString(drc[rowIndexs[0]]["I_SHENPIL"]);
                txtJHBGSPYJ.Text = Convert.ToString(drc[rowIndexs[0]]["S_SHENPIYJ"]);
            }
            else if (LaiHanLX == eLaiHanLX.计划指标注销)
            {
                txtJHBGSPYJ.Text = Convert.ToString(drc[rowIndexs[0]]["S_SHENPIYJ"]);
            }
            else if (LaiHanLX == eLaiHanLX.并户 || LaiHanLX == eLaiHanLX.销户 || LaiHanLX == eLaiHanLX.销表 ||
                     LaiHanLX == eLaiHanLX.退款 || (int) LaiHanLX >= 20)
            {
                cbTongYi.Checked = Convert.ToInt32(drc[rowIndexs[0]]["I_SHENPIJG"]) == 1;
                cbBuTongY.Checked = !cbTongYi.Checked;
                txtHuJiSPYJ.Text = Convert.ToString(drc[rowIndexs[0]]["S_SHENPIYJ"]);
            }
            else if (LaiHanLX == eLaiHanLX.分户)
            {
                if (LaiHanLC == eLaiHanLCBH.业务员)
                {
                    txtHuJiSPYJ.Text = Convert.ToString(drc[0]["S_YEWUY"]).Trim() == ""
                        ? "拟同意，报批。"
                        : Convert.ToString(drc[0]["S_YEWUY"]);
                    isNowFlow = drc[0]["S_YEWUY"].ToString().Length > 0;
                }
                else if (LaiHanLC == eLaiHanLCBH.主任)
                {
                    txtHuJiSPYJ.Text = Convert.ToString(drc[0]["S_ZHUREN"]) == ""
                        ? "拟同意。"
                        : Convert.ToString(drc[0]["S_ZHUREN"]);
                    isNowFlow = drc[0]["S_ZHUREN"].ToString().Length > 0;
                }
                else if (LaiHanLC == eLaiHanLCBH.节水科)
                {
                    txtHuJiSPYJ.Text = Convert.ToString(drc[0]["S_JieShui"]) == ""
                        ? "拟同意。"
                        : Convert.ToString(drc[0]["S_JieShui"]);
                    isNowFlow = drc[0]["S_JieShui"].ToString().Length > 0;
                }
                else if (LaiHanLC == eLaiHanLCBH.计财科)
                {
                    txtHuJiSPYJ.Text = Convert.ToString(drc[0]["S_JiCAI"]) == ""
                        ? "同意"
                        : Convert.ToString(drc[0]["S_JiCAI"]);
                    isNowFlow = drc[0]["S_JiCAI"].ToString().Length > 0;
                }

                if (!isNowFlow)
                {
                    cbTongYi.Checked = false;
                    cbBuTongY.Checked = false;
                }
                else
                {
                    cbTongYi.Checked = Convert.ToInt32(drc[0]["S_SHENPI"]) == 1 ? true : false;
                    ;
                    cbBuTongY.Checked = !cbTongYi.Checked;
                }
            }
            else if (LaiHanLX == eLaiHanLX.改户)
            {
                if (drc != null && drc.Count > 0)
                {
                    cbTongYi.Checked = Convert.ToInt32(drc[rowIndexs[0]]["I_SHENPIJG"]) == 1;
                    cbBuTongY.Checked = !cbTongYi.Checked;
                    if (LaiHanLC == eLaiHanLCBH.计财科)
                        txtHuJiSPYJ.Text = Convert.ToString(drc[rowIndexs[0]]["S_SHENPIYJ"]).Trim() == ""
                            ? "同意"
                            : Convert.ToString(drc[rowIndexs[0]]["S_SHENPIYJ"]);
                    else
                        txtHuJiSPYJ.Text = Convert.ToString(drc[rowIndexs[0]]["S_SHENPIYJ"]).Trim() == ""
                            ? "拟同意，报批。"
                            : Convert.ToString(drc[rowIndexs[0]]["S_SHENPIYJ"]);
                }
            }

            if (!isNowFlow)
            {
                //为上一步骤,重置意见框
                if (LaiHanLC == eLaiHanLCBH.业务员)
                {
                    txtYiJian.Text = "";
                    txtJHBGSPYJ.Text = "";
                    txtHuJiSPYJ.Text = "";
                }
                else
                {
                    if (LaiHanLX == eLaiHanLX.月度 || LaiHanLX == eLaiHanLX.年度 || LaiHanLX == eLaiHanLX.基建调整 || LaiHanLX == eLaiHanLX.计划变更 ||
                        LaiHanLX == eLaiHanLX.表计因素注销)
                    {
                        if (LaiHanLC == eLaiHanLCBH.处长)
                        {
                            txtYiJian.Text = "同意。";
                            txtJHBGSPYJ.Text = "同意。";
                            txtHuJiSPYJ.Text = "同意。";
                        }
                        else
                        {
                            txtYiJian.Text = "拟同意。";
                            txtJHBGSPYJ.Text = "拟同意。";
                            txtHuJiSPYJ.Text = "拟同意。";
                        }
                    }
                    else if (LaiHanLX == eLaiHanLX.分户 || LaiHanLX == eLaiHanLX.并户 || LaiHanLX == eLaiHanLX.改户
                            || LaiHanLX == eLaiHanLX.退款 || LaiHanLX == eLaiHanLX.销表 || LaiHanLX == eLaiHanLX.销户
                            || (int) LaiHanLX >= 20)
                    {
                        if (LaiHanLC == eLaiHanLCBH.计财科)
                        {
                            txtYiJian.Text = "同意。";
                            txtJHBGSPYJ.Text = "同意。";
                            txtHuJiSPYJ.Text = "同意。";
                        }
                        else
                        {
                            txtYiJian.Text = "同意。";
                            txtJHBGSPYJ.Text = "同意。";
                            txtHuJiSPYJ.Text = "同意。";
                        }
                    }
                }

                cbBuTongY.Checked = false;
                cbTongYi.Checked = false;
            }

            return isNowFlow;
        }

        /// <summary>
        ///     根据情况设置是否启用编辑(1.当前流程已确认 2.当前流程尚未操作过)
        /// </summary>
        public void SetShenPiContent(bool enabled)
        {
            var m = -1;
            var tbPre = "";
            if (enabled && Y == BusinessTool.GetWaterYM() / 100) m = BusinessTool.GetWaterYM() % 100;
            if (LaiHanLX == eLaiHanLX.年度)
            {
                txtYiJian.ClientEnabled = enabled;
                txtSplM1.ClientEnabled = enabled;
                txtSplM2.ClientEnabled = enabled;
                txtSplM3.ClientEnabled = enabled;
                txtSplM4.ClientEnabled = enabled;
                txtSplM5.ClientEnabled = enabled;
                txtSplM6.ClientEnabled = enabled;
                txtSplM7.ClientEnabled = enabled;
                txtSplM8.ClientEnabled = enabled;
                txtSplM9.ClientEnabled = enabled;
                txtSplM10.ClientEnabled = enabled;
                txtSplM11.ClientEnabled = enabled;
                txtSplM12.ClientEnabled = enabled;
                txtSplMSUM.ClientEnabled = enabled;
                tbPre = "txtSplM";
            }
            else if (LaiHanLX == eLaiHanLX.基建调整)
            {
                txtYiJian.ClientEnabled = enabled;
                txtBNM1.ClientEnabled = enabled;
                txtBNM2.ClientEnabled = enabled;
                txtBNM3.ClientEnabled = enabled;
                txtBNM4.ClientEnabled = enabled;
                txtBNM5.ClientEnabled = enabled;
                txtBNM6.ClientEnabled = enabled;
                txtBNM7.ClientEnabled = enabled;
                txtBNM8.ClientEnabled = enabled;
                txtBNM9.ClientEnabled = enabled;
                txtBNM10.ClientEnabled = enabled;
                txtBNM11.ClientEnabled = enabled;
                txtBNM12.ClientEnabled = enabled;
                txtBNMSUM.ClientEnabled = enabled;
                txtXNM1.ClientEnabled = enabled;
                txtXNM2.ClientEnabled = enabled;
                txtXNM3.ClientEnabled = enabled;
                txtXNM4.ClientEnabled = enabled;
                txtXNM5.ClientEnabled = enabled;
                txtXNM6.ClientEnabled = enabled;
                txtXNM7.ClientEnabled = enabled;
                txtXNM8.ClientEnabled = enabled;
                txtXNM9.ClientEnabled = enabled;
                txtXNM10.ClientEnabled = enabled;
                txtXNM11.ClientEnabled = enabled;
                txtXNM12.ClientEnabled = enabled;
                txtXNMSUM.ClientEnabled = enabled;
                tbPre = "txtBNM";
            }
            else if (LaiHanLX == eLaiHanLX.计划变更 || LaiHanLX == eLaiHanLX.表计因素注销 || LaiHanLX == eLaiHanLX.月度)
            {
                txtJHBGSPYJ.ClientEnabled = enabled;
                txtJHBGSPL.ClientEnabled = enabled;
            }
            else if (LaiHanLX == eLaiHanLX.计划指标注销)
            {
                txtJHBGSPYJ.ClientEnabled = enabled;
            }
            else if (LaiHanLX == eLaiHanLX.改户 || LaiHanLX == eLaiHanLX.分户 || LaiHanLX == eLaiHanLX.并户 ||
                     LaiHanLX == eLaiHanLX.销户 || LaiHanLX == eLaiHanLX.销表 || LaiHanLX == eLaiHanLX.退款
                     || (int) LaiHanLX >= 20)
            {
                cbBuTongY.ClientEnabled = enabled;
                cbTongYi.ClientEnabled = enabled;
                txtHuJiSPYJ.ClientEnabled = enabled;
            }

            //当前为年调整及基建调整,当启用时,如果为当前年,当前水量年月之前的仍然禁用
            if (enabled && tbPre != "")
                for (var i = 1; i <= m; i++)
                {
                    var tb = (ASPxTextBox) FindControl(tbPre + i);
                    tb.ClientEnabled = false;
                }
        }

        /// <summary>
        ///     根据来函加载信息
        /// </summary>
        public void LoadInfo(YS_LH_LAIHANXX laihanxx)
        {
            if (laihanxx.I_TZY != null) Y = (int) laihanxx.I_TZY;
            //获取当前或上一步骤审批量与意见(已经确认过未提交,则显示当前的. 未确认过的则是上一步骤的)
            var drc = _sphelper.P_YS_LHGETSHENPIYJS((int) LaiHanLX, laihanxx.S_LAIHANBH).Tables[0].Rows;
            if (LoadShenPiContent(drc))
                SetShenPiContent(false);
            else
                SetShenPiContent(true);
            //加载默认意见 业务员时
            if (laihanxx.I_LIUCHENGBH == (int) eLaiHanLCBH.业务员)
            {
                //加载默认设置的业务员意见及内容
                UCLHSuggestYiJians.LoadSuggestYiJians((int) eLaiHanLCBH.业务员);
                tdNDOpenSuggestYJs.Visible = true;
                tdJHBGOpenSuggestYJs.Visible = true;
                if (laihanxx.I_LAIHANLX == (int) eLaiHanLX.计划指标注销)
                {
                    var result = _sphelper.P_YSLH_JIHUAZBZXXXHQ(laihanxx.S_LAIHANBH, laihanxx.S_YONGHUBH, 0).Tables[0];
                    int y = 0;
                    int m = 0;
                    double total = 0;
                    for (var i = 0; i < result.Rows.Count; i++)
                    {
                        if (i == 0)
                        {
                            var ym = result.Rows[i]["I_YM"].ToString();
                            y = Convert.ToInt32(ym.Substring(0, 4));
                            m = Convert.ToInt32(ym.Substring(4, 2));
                        }

                        total += Convert.ToDouble(result.Rows[i]["N_HEXIAOJE"]);
                    }

                    var content =
                        string.Format(
                            "经核查，该单位因         原因，{0}年{1}月及以前尚欠的超计划加价水费共计{2}元已无法收缴 。根据《中华人民共和国行政许可法》第七十条第三款，拟注销{0}年{1}月前无法执行的用水计划指标。",
                            y, m, total);
                    txtYiJian.Text = content;
                }
            }
        }

        /// <summary>
        ///     获取审批内容
        /// </summary>
        /// <param name="laihanxx">来函信息</param>
        /// <param name="bn">是否本年</param>
        /// <returns>仅当类型为基建调整,并且bn为true时返回本年. bn为false时返回下年.</returns>
        private object GetShenPiNR(YS_LH_LAIHANXX laihanxx, bool bn)
        {
            object r;
            if (LaiHanLX == eLaiHanLX.月度)
            {
                var dr = _YS_LH_YUETIAOZBLL
                    .SelectYS_LH_YUETIAOZsDynamic("I_JLZT=0 AND S_LAIHANBH='" + laihanxx.S_LAIHANBH + "'", null).Rows[0];
                var idT = Convert.ToInt32(dr["ID"]);
                var item = _YS_LH_YUETIAOZBLL.SelectYS_LH_YUETIAOZ(idT);
                item.S_CAOZUORQM = LoginInfo.CurrentUser.ElectronSign;
                if (laihanxx.I_LIUCHENGBH == (int) eLaiHanLCBH.业务员)
                {
                    item.I_YEWUYJY = Convert.ToInt32(txtJHBGSPL.Text);
                    item.S_YEWUYJY = Convert.ToString(txtJHBGSPYJ.Text);
                }
                else if (laihanxx.I_LIUCHENGBH == (int) eLaiHanLCBH.主任)
                {
                    item.I_ZHUREN = Convert.ToInt32(txtJHBGSPL.Text);
                    item.S_ZHUREN = Convert.ToString(txtJHBGSPYJ.Text);
                }
                else if (laihanxx.I_LIUCHENGBH == (int) eLaiHanLCBH.节水科)
                {
                    item.I_JIESHUIKZ = Convert.ToInt32(txtJHBGSPL.Text);
                    item.S_JIESHUIKZ = Convert.ToString(txtJHBGSPYJ.Text);
                }
                else if (laihanxx.I_LIUCHENGBH == (int) eLaiHanLCBH.计财科)
                {
                    item.I_JICAIKZ = Convert.ToInt32(txtJHBGSPL.Text);
                    item.S_JICAIKZ = Convert.ToString(txtJHBGSPYJ.Text);
                }
                else if (laihanxx.I_LIUCHENGBH == (int) eLaiHanLCBH.处长)
                {
                    item.I_CHUZHANG = Convert.ToInt32(txtJHBGSPL.Text);
                    item.S_CHUZHANG = Convert.ToString(txtJHBGSPYJ.Text);
                }

                r = item;
            }
            else if (LaiHanLX == eLaiHanLX.年度)
            {
                var item = new YS_LH_NIANTIAOZ();
                item.S_CAOZUORQM = LoginInfo.CurrentUser.ElectronSign;
                item.D_SHURURQ = DateTime.Now;
                item.I_JLZT = 0;
                item.I_LIUCHENGBH = (int) LaiHanLC;
                item.I_SHURUR = LoginInfo.CurrentUser.UserID;
                item.I_Y = laihanxx.I_TZY;
                item.ID = 0;
                item.S_LAIHANBH = laihanxx.S_LAIHANBH;
                item.S_YONGHUBH = laihanxx.S_YONGHUBH;
                item.S_ZHANDIANBH = laihanxx.S_ZHANDIANBH;
                item.S_SHENPIYJ = txtYiJian.Text;
                item.I_M1 = int.Parse(txtSplM1.Text);
                item.I_M2 = int.Parse(txtSplM2.Text);
                item.I_M3 = int.Parse(txtSplM3.Text);
                item.I_M4 = int.Parse(txtSplM4.Text);
                item.I_M5 = int.Parse(txtSplM5.Text);
                item.I_M6 = int.Parse(txtSplM6.Text);
                item.I_M7 = int.Parse(txtSplM7.Text);
                item.I_M8 = int.Parse(txtSplM8.Text);
                item.I_M9 = int.Parse(txtSplM9.Text);
                item.I_M10 = int.Parse(txtSplM10.Text);
                item.I_M11 = int.Parse(txtSplM11.Text);
                item.I_M12 = int.Parse(txtSplM12.Text);
                r = item;
            }
            else if (LaiHanLX == eLaiHanLX.基建调整)
            {
                var item = new YS_LH_JIJIANTZ();
                item.S_CAOZUORQM = LoginInfo.CurrentUser.ElectronSign;
                item.D_SHURURQ = DateTime.Now;
                item.I_JLZT = 0;
                item.I_LIUCHENGBH = (int) LaiHanLC;
                item.I_SHURUR = LoginInfo.CurrentUser.UserID;
                item.ID = 0;
                item.S_LAIHANBH = laihanxx.S_LAIHANBH;
                item.S_YONGHUH = laihanxx.S_YONGHUBH;
                item.S_ZHANDIANBH = laihanxx.S_ZHANDIANBH;
                item.S_GUANLIKBH = laihanxx.S_GUANLIKBH;
                //本年
                if (bn)
                {
                    item.I_Y = laihanxx.I_TZY;
                    item.S_SHENPIYJ = txtYiJian.Text;
                    item.I_M1 = int.Parse(txtBNM1.Text);
                    item.I_M2 = int.Parse(txtBNM2.Text);
                    item.I_M3 = int.Parse(txtBNM3.Text);
                    item.I_M4 = int.Parse(txtBNM4.Text);
                    item.I_M5 = int.Parse(txtBNM5.Text);
                    item.I_M6 = int.Parse(txtBNM6.Text);
                    item.I_M7 = int.Parse(txtBNM7.Text);
                    item.I_M8 = int.Parse(txtBNM8.Text);
                    item.I_M9 = int.Parse(txtBNM9.Text);
                    item.I_M10 = int.Parse(txtBNM10.Text);
                    item.I_M11 = int.Parse(txtBNM11.Text);
                    item.I_M12 = int.Parse(txtBNM12.Text);
                }
                else
                {
                    item.I_Y = laihanxx.I_TZY + 1;
                    item.S_SHENPIYJ = "";
                    item.I_M1 = int.Parse(txtXNM1.Text);
                    item.I_M2 = int.Parse(txtXNM2.Text);
                    item.I_M3 = int.Parse(txtXNM3.Text);
                    item.I_M4 = int.Parse(txtXNM4.Text);
                    item.I_M5 = int.Parse(txtXNM5.Text);
                    item.I_M6 = int.Parse(txtXNM6.Text);
                    item.I_M7 = int.Parse(txtXNM7.Text);
                    item.I_M8 = int.Parse(txtXNM8.Text);
                    item.I_M9 = int.Parse(txtXNM9.Text);
                    item.I_M10 = int.Parse(txtXNM10.Text);
                    item.I_M11 = int.Parse(txtXNM11.Text);
                    item.I_M12 = int.Parse(txtXNM12.Text);
                }

                r = item;
            }
            else if (LaiHanLX == eLaiHanLX.计划变更)
            {
                var item = new YS_LH_JIHUABG();
                item.S_CAOZUORQM = LoginInfo.CurrentUser.ElectronSign;
                item.D_SHURURQ = DateTime.Now;
                item.I_SHURUR = LoginInfo.CurrentUser.UserID;
                item.I_JLZT = 0;
                item.I_LIUCHENGBH = (int) LaiHanLC;
                item.ID = 0;
                item.S_LAIHANBH = laihanxx.S_LAIHANBH;
                item.S_YONGHUH = laihanxx.S_YONGHUBH;
                item.I_SHENPIL = decimal.Parse(txtJHBGSPL.Text);
                item.S_SHENPIYJ = txtJHBGSPYJ.Text;
                //从登记中复制对应的备份营业账信息
                var drc = new YS_LH_JIHUABGBLL()
                    .SelectYS_LH_JIHUABGsDynamic("I_JLZT=0 and S_LAIHANBH=" + laihanxx.S_LAIHANBH, null).Rows;
                var indexes = LaiHanLCTools.GetNeedRowIndexs(drc, (int) laihanxx.I_LAIHANLX, eLaiHanLCBH.登记);
                item.I_FEIYONGBH = Convert.ToInt32(drc[indexes[0]]["I_FEIYONGBH"]);
                item.I_JIAJIACS = Convert.ToInt32(drc[indexes[0]]["I_JIAJIACS"]);
                item.I_JIAJIAYSL = Convert.ToInt32(drc[indexes[0]]["I_JIAJIAYSL"]);
                item.I_SHIYONGSL = Convert.ToInt32(drc[indexes[0]]["I_SHIYONGSL"]);
                item.N_SHISHOUJE = Convert.ToDouble(drc[indexes[0]]["N_SHISHOUJE"]);
                item.N_YINGSHOUJE = Convert.ToDouble(drc[indexes[0]]["N_YINGSHOUJE"]);
                item.N_YSJ = Convert.ToDouble(drc[indexes[0]]["N_YSJ"]);
                item.N_JIAJIAJE = Convert.ToDouble(drc[indexes[0]]["N_JIAJIAJE"]);
                item.I_ZWYM = Convert.ToInt32(drc[indexes[0]]["I_ZWYM"]);
                item.N_QIANFEIJE = Convert.ToDouble(drc[indexes[0]]["N_QIANFEIJE"]);
                item.I_YUANJIHUA = Convert.ToInt32(drc[indexes[0]]["I_YUANJIHUA"]);
                /*计算当前审批核销金额*/
                //1.获取计划量
                var jhl = Convert.ToInt32(drc[indexes[0]]["I_SHIYONGSL"]) -
                          Convert.ToInt32(drc[indexes[0]]["I_JIAJIAYSL"]);
                item.N_HEXIAOJE = Convert.ToDouble(item.I_SHENPIL - jhl) * item.N_YSJ *
                                  Convert.ToDouble(item.I_JIAJIACS);
                item.D_CAOZUOSJ = BusinessTool.GetDataBaseDateTime();
                item.S_CAOZUOR = LoginInfo.CurrentUser.UserID.ToString();
                r = item;
            }
            else if (LaiHanLX == eLaiHanLX.表计因素注销)
            {
                var item = new YS_LH_BIAOJIYSZX();
                item.D_SHURURQ = DateTime.Now;
                item.I_SHURUR = LoginInfo.CurrentUser.UserID;
                item.I_JLZT = 0;
                item.I_LIUCHENGBH = (int) LaiHanLC;
                item.ID = 0;
                item.S_LAIHANBH = laihanxx.S_LAIHANBH;
                item.S_YONGHUH = laihanxx.S_YONGHUBH;
                item.I_SHENPIL = decimal.Parse(txtJHBGSPL.Text);
                item.S_SHENPIYJ = txtJHBGSPYJ.Text;
                //从登记中复制对应的备份营业账信息
                var drc = new YS_LH_BIAOJIYSZXProcess()
                    .SelectYS_LH_BIAOJIYSZXesDynamic("I_JLZT=0 and S_LAIHANBH=" + laihanxx.S_LAIHANBH, null).Rows;
                var indexes = LaiHanLCTools.GetNeedRowIndexs(drc, (int) laihanxx.I_LAIHANLX, eLaiHanLCBH.登记);
                item.I_FEIYONGBH = Convert.ToInt32(drc[indexes[0]]["I_FEIYONGBH"]);
                item.I_JIAJIACS = Convert.ToInt32(drc[indexes[0]]["I_JIAJIACS"]);
                item.I_JIAJIAYSL = Convert.ToInt32(drc[indexes[0]]["I_JIAJIAYSL"]);
                item.I_SHIYONGSL = Convert.ToInt32(drc[indexes[0]]["I_SHIYONGSL"]);
                item.N_SHISHOUJE = Convert.ToDouble(drc[indexes[0]]["N_SHISHOUJE"]);
                item.N_YINGSHOUJE = Convert.ToDouble(drc[indexes[0]]["N_YINGSHOUJE"]);
                item.N_YSJ = Convert.ToDouble(drc[indexes[0]]["N_YSJ"]);
                item.N_JIAJIAJE = Convert.ToDouble(drc[indexes[0]]["N_JIAJIAJE"]);
                item.I_ZWYM = Convert.ToInt32(drc[indexes[0]]["I_ZWYM"]);
                item.N_QIANFEIJE = Convert.ToDouble(drc[indexes[0]]["N_QIANFEIJE"]);
                item.I_YUANJIHUA = Convert.ToInt32(drc[indexes[0]]["I_YUANJIHUA"]);
                /*计算当前审批核销金额*/
                //1.获取计划量
                var jhl = Convert.ToInt32(drc[indexes[0]]["I_SHIYONGSL"]) -
                          Convert.ToInt32(drc[indexes[0]]["I_JIAJIAYSL"]);
                item.N_HEXIAOJE = Convert.ToDouble(item.I_SHENPIL - jhl) * item.N_YSJ *
                                  Convert.ToDouble(item.I_JIAJIACS);
                item.D_CAOZUOSJ = BusinessTool.GetDataBaseDateTime();
                item.S_CAOZUOR = LoginInfo.CurrentUser.UserID.ToString();
                r = item;
            }
            else if (LaiHanLX == eLaiHanLX.计划指标注销)
            {
                var item = new YS_LH_JIHUAZBZX();
                item.D_SHURURQ = DateTime.Now;
                item.I_SHURUR = LoginInfo.CurrentUser.UserID;
                item.I_JLZT = 0;
                item.I_LIUCHENGBH = (int) LaiHanLC;
                item.ID = 0;
                item.S_LAIHANBH = laihanxx.S_LAIHANBH;
                item.S_SHENPIYJ = txtJHBGSPYJ.Text;
                item.D_CAOZUOSJ = BusinessTool.GetDataBaseDateTime();
                item.S_CAOZUOR = LoginInfo.CurrentUser.UserID.ToString();
                r = item;
            }
            else if (LaiHanLX == eLaiHanLX.并户)
            {
                var item = new YS_LH_BINGHU();
                item.D_SHURURQ = DateTime.Now;
                item.I_SHURUR = LoginInfo.CurrentUser.UserID;
                item.I_JLZT = 0;
                item.I_LIUCHENGBH = (int) LaiHanLC;
                item.ID = 0;
                item.S_LAIHANBH = laihanxx.S_LAIHANBH;
                if ((int) LaiHanLC == (int) eLaiHanLCBH.业务员)
                    item.I_SHENPIJG = 1;
                else
                    item.I_SHENPIJG = cbTongYi.Checked ? 1 : 0;
                item.S_SHENPIYJ = txtHuJiSPYJ.Text;
                r = item;
            }
            else if (LaiHanLX == eLaiHanLX.销户)
            {
                var item = new YS_LH_XIAOHU();
                item.D_SHURURQ = DateTime.Now;
                item.I_SHURUR = LoginInfo.CurrentUser.UserID;
                item.I_JLZT = 0;
                item.I_LIUCHENGBH = (int) LaiHanLC;
                item.ID = 0;
                item.S_LAIHANBH = laihanxx.S_LAIHANBH;
                if ((int) LaiHanLC == (int) eLaiHanLCBH.业务员)
                    item.I_SHENPIJG = (int) eLaiHanSPJG.同意;
                else
                    item.I_SHENPIJG = cbTongYi.Checked ? (int) eLaiHanSPJG.同意 : (int) eLaiHanSPJG.不同意;
                item.S_SHENPIYJ = txtHuJiSPYJ.Text;
                r = item;
            }
            else if (LaiHanLX == eLaiHanLX.销表)
            {
                var item = new YS_LH_XIAOBIAO();
                item.D_SHURURQ = DateTime.Now;
                item.I_SHURUR = LoginInfo.CurrentUser.UserID;
                item.I_JLZT = 0;
                item.I_LIUCHENGBH = (int) LaiHanLC;
                item.ID = 0;
                item.S_LAIHANBH = laihanxx.S_LAIHANBH;
                if ((int) LaiHanLC == (int) eLaiHanLCBH.业务员)
                    item.I_SHENPIJG = (int) eLaiHanSPJG.同意;
                else
                    item.I_SHENPIJG = cbTongYi.Checked ? (int) eLaiHanSPJG.同意 : (int) eLaiHanSPJG.不同意;
                item.S_SHENPIYJ = txtHuJiSPYJ.Text;
                r = item;
            }
            else if (LaiHanLX == eLaiHanLX.退款)
            {
                var item = new YS_LH_TUIKUAN();
                item.D_SHURURQ = DateTime.Now;
                item.I_SHURUR = LoginInfo.CurrentUser.UserID;
                item.I_JLZT = 0;
                item.I_LIUCHENGBH = (int) LaiHanLC;
                item.ID = 0;
                item.S_LAIHANBH = laihanxx.S_LAIHANBH;
                if ((int) LaiHanLC == (int) eLaiHanLCBH.业务员)
                    item.I_SHENPIJG = (int) eLaiHanSPJG.同意;
                else
                    item.I_SHENPIJG = cbTongYi.Checked ? (int) eLaiHanSPJG.同意 : (int) eLaiHanSPJG.不同意;
                item.S_SHENPIYJ = txtHuJiSPYJ.Text;
                item.I_DANGQIAN = 1;
                r = item;
            }
            else if (LaiHanLX == eLaiHanLX.分户)
            {
                var item = new YS_LH_FENHUXX();
                item.D_CAOZUORQ = DateTime.Now;
                item.S_CAOZUOR = LoginInfo.CurrentUser.UserID.ToString();
                item.I_JLZT = 0;
                //
                item.S_YEWUY = txtHuJiSPYJ.Text;
                item.S_JIESHUI = txtHuJiSPYJ.Text;
                item.S_ZHUREN = txtHuJiSPYJ.Text;
                item.S_JICAI = txtHuJiSPYJ.Text;
                item.ID = 0;
                item.S_LAIHANBH = laihanxx.S_LAIHANBH;
                item.S_SHENPI = Convert.ToString(cbTongYi.Checked ? (int) eLaiHanSPJG.同意 : (int) eLaiHanSPJG.不同意);
                r = item;
            }
            else if (LaiHanLX == eLaiHanLX.改户)
            {
                var item = new YS_LH_GAIHUXX();
                item.D_SHURURQ = DateTime.Now;
                item.I_SHURUR = LoginInfo.CurrentUser.UserID;
                item.I_JLZT = 0;
                item.I_LIUCHENGBH = (int) LaiHanLC;
                item.ID = 0;
                item.S_LAIHANBH = laihanxx.S_LAIHANBH;
                if ((int) LaiHanLC == (int) eLaiHanLCBH.业务员)
                    item.I_SHENPIJG = (int) eLaiHanSPJG.同意;
                else
                    item.I_SHENPIJG = cbTongYi.Checked ? (int) eLaiHanSPJG.同意 : (int) eLaiHanSPJG.不同意;
                item.S_SHENPIYJ = txtHuJiSPYJ.Text;
                r = item;
            }
            else if ((int) LaiHanLX > 20)
            {
                var item = new QS_LH_TONGYONGBZYJ();
                item.D_SHURURQ = DateTime.Now;
                item.I_SHURUR = LoginInfo.CurrentUser.UserID;
                item.I_JLZT = 0;
                item.I_LIUCHENGBH = (int) LaiHanLC;
                item.ID = 0;
                item.S_LAIHANBH = laihanxx.S_LAIHANBH;
                if ((int) LaiHanLC == (int) eLaiHanLCBH.业务员)
                    item.I_SHENPIJG = 1;
                else
                    item.I_SHENPIJG = cbTongYi.Checked ? 1 : 0;
                item.S_SHENPIYJ = txtHuJiSPYJ.Text;
                r = item;
            }
            else
            {
                r = new object();
            }

            return r;
        }

        /// <summary>
        ///     提交审批内容
        /// </summary>
        /// <param name="lhxx">来函信息</param>
        /// <param name="tijiao">是否插入下一流程(两种情况) 1:确认 仅插入审批内容,不插入下一步流程 2:提交 插入审批内容,更新当前流程完成时间,插入下一流程</param>
        public void CommitContent(YS_LH_LAIHANXX lhxx, bool tijiao)
        {
            if (tijiao)
            {
                //审批操作默认为同意,涉及来函需从确认信息中获取同意信息
                var spjg = eLaiHanSPJG.同意;
                if (LaiHanLX == eLaiHanLX.并户 || LaiHanLX == eLaiHanLX.分户 || LaiHanLX == eLaiHanLX.改户 ||
                    LaiHanLX == eLaiHanLX.退款 || LaiHanLX == eLaiHanLX.销表 || LaiHanLX == eLaiHanLX.销户 ||
                    (int) LaiHanLX > 20)
                {
                    var drcT = new SpHelper().P_YS_LHGETSHENPIYJS((int) lhxx.I_LAIHANLX, lhxx.S_LAIHANBH).Tables[0]
                        .Rows;
                    if (drcT.Count == 0) throw new Exception("来函信息副表数据异常.请检查数据.");
                    //20190325 add 分户表里没有I_LIUCHENGBH字段
                    if (LaiHanLX == eLaiHanLX.分户)
                    {
                        spjg = Convert.ToString(drcT[0]["S_SHENPI"]) == "1" ? eLaiHanSPJG.同意 : eLaiHanSPJG.不同意;
                    }
                    else
                    { 
                        for (var i = 0; i < drcT.Count; i++)
                            if (Convert.ToString(drcT[i]["I_LIUCHENGBH"]) == lhxx.I_LIUCHENGBH.ToString())
                                spjg = Convert.ToString(drcT[0][LaiHanLX == eLaiHanLX.分户 ? "S_SHENPI" : "I_SHENPIJG"]) ==
                                       "1"
                                    ? eLaiHanSPJG.同意
                                    : eLaiHanSPJG.不同意;
                    }
                    //if (this.LaiHanLX == eLaiHanLX.分户)
                    //{
                    //    spjg = Convert.ToInt32(drcT[0]["S_SHENPI"])== 1 ? eLaiHanSPJG.同意 : eLaiHanSPJG.不同意;
                    //}
                    //else
                    //{
                    //    spjg = Convert.ToInt32(drcT[0]["I_SHENPIJG"]) == 1 ? eLaiHanSPJG.同意 : eLaiHanSPJG.不同意; 
                    //}                    
                }

                LaiHanLCTools.AddNextFlow(lhxx, spjg, false);
                return;
            }

            if (LaiHanLX == eLaiHanLX.月度)
            {
                //获取审批内容
                var spItem = (YS_LH_YUETIAOZ) GetShenPiNR(lhxx, false);
                //插入数据库
                _YS_LH_YUETIAOZBLL.InsertOrUpdate(spItem);
            }
            else if (LaiHanLX == eLaiHanLX.年度)
            {
                //获取审批内容
                var spItem = (YS_LH_NIANTIAOZ) GetShenPiNR(lhxx, false);
                //判断是否已存在(之前做过修改则会存在)
                var drc = _YS_LH_NIANTIAOZBLL.SelectYS_LH_NIANTIAOZsDynamic(
                    "I_JLZT=0 AND S_LAIHANBH=" + lhxx.S_LAIHANBH + " and I_LIUCHENGBH=" + lhxx.I_LIUCHENGBH, null).Rows;
                if (drc.Count == 1) spItem.ID = Convert.ToInt32(drc[0]["ID"]);
                //插入数据库
                _YS_LH_NIANTIAOZBLL.InsertOrUpdate(spItem);
            }
            else if (LaiHanLX == eLaiHanLX.基建调整)
            {
                //获取本年
                var spItem = (YS_LH_JIJIANTZ) GetShenPiNR(lhxx, true);
                //本年,判断是否已存在(之前做过修改则会存在)
                var drc = _YS_LH_JIJIANTZBLL.SelectYS_LH_JIJIANTZsDynamic(
                    "I_JLZT=0 AND S_LAIHANBH=" + lhxx.S_LAIHANBH + " and I_Y=" + lhxx.I_TZY + " and I_LIUCHENGBH=" +
                    lhxx.I_LIUCHENGBH, null).Rows;
                if (drc.Count == 1) spItem.ID = Convert.ToInt32(drc[0]["ID"]);
                //插入数据库
                _YS_LH_JIJIANTZBLL.InsertOrUpdate(spItem);
                //获取下年
                spItem = (YS_LH_JIJIANTZ) GetShenPiNR(lhxx, false);
                //下年,判断是否已存在(之前做过修改则会存在)
                drc = _YS_LH_JIJIANTZBLL
                    .SelectYS_LH_JIJIANTZsDynamic(
                        "I_JLZT=0 AND S_LAIHANBH=" + lhxx.S_LAIHANBH + " and I_Y=" + (lhxx.I_TZY + 1) +
                        " and I_LIUCHENGBH=" + lhxx.I_LIUCHENGBH, null).Rows;
                if (drc.Count == 1) spItem.ID = Convert.ToInt32(drc[0]["ID"]);
                //插入数据库
                _YS_LH_JIJIANTZBLL.InsertOrUpdate(spItem);
            }
            else if (LaiHanLX == eLaiHanLX.计划变更)
            {
                //获取审批内容
                var spItem = (YS_LH_JIHUABG) GetShenPiNR(lhxx, false);
                //判断是否已存在(之前做过修改则会存在)
                var drc = _YS_LH_JIHUABGBLL
                    .SelectYS_LH_JIHUABGsDynamic(
                        "I_JLZT=0 AND S_LAIHANBH=" + lhxx.S_LAIHANBH + " and I_LIUCHENGBH=" + lhxx.I_LIUCHENGBH, null)
                    .Rows;
                if (drc.Count == 1) spItem.ID = Convert.ToInt32(drc[0]["ID"]);
                //插入数据库
                _YS_LH_JIHUABGBLL.InsertOrUpdate(spItem);
            }
            else if (LaiHanLX == eLaiHanLX.表计因素注销)
            {
                //获取审批内容
                var spItem = (YS_LH_BIAOJIYSZX) GetShenPiNR(lhxx, false);
                //判断是否已存在(之前做过修改则会存在)
                var drc = _YS_LH_BIAOJIYSZXProcess.SelectYS_LH_BIAOJIYSZXesDynamic(
                    "I_JLZT=0 AND S_LAIHANBH=" + lhxx.S_LAIHANBH + " and I_LIUCHENGBH=" + lhxx.I_LIUCHENGBH, null).Rows;
                if (drc.Count == 1) spItem.ID = Convert.ToInt32(drc[0]["ID"]);
                //插入数据库
                _YS_LH_BIAOJIYSZXProcess.InsertOrUpdate(spItem);
            }
            else if (LaiHanLX == eLaiHanLX.计划指标注销)
            {
                //获取审批内容
                var spItem = (YS_LH_JIHUAZBZX) GetShenPiNR(lhxx, false);
                //判断是否已存在(之前做过修改则会存在)
                var drc = _YS_LH_JIHUAZBZXProcess.SelectYS_LH_JIHUAZBZXesDynamic(
                    "I_JLZT=0 AND S_LAIHANBH=" + lhxx.S_LAIHANBH + " and I_LIUCHENGBH=" + lhxx.I_LIUCHENGBH, null).Rows;
                if (drc.Count == 1) spItem.ID = Convert.ToInt32(drc[0]["ID"]);
                //插入数据库
                _YS_LH_JIHUAZBZXProcess.InsertOrUpdate(spItem);
            }
            else if (LaiHanLX == eLaiHanLX.并户)
            {
                //获取审批内容
                var spItem = (YS_LH_BINGHU) GetShenPiNR(lhxx, false);
                //判断是否已存在(之前做过修改则会存在)
                var drc = _YS_LH_BINGHUBLL
                    .SelectYS_LH_BINGHUsDynamic(
                        "I_JLZT=0 AND S_LAIHANBH=" + lhxx.S_LAIHANBH + " and I_LIUCHENGBH=" + lhxx.I_LIUCHENGBH, null)
                    .Rows;
                if (drc.Count == 1) spItem.ID = Convert.ToInt32(drc[0]["ID"]);
                //插入数据库
                _YS_LH_BINGHUBLL.InsertOrUpdate(spItem);
                /*
                //获取审批结果
                spjg = (eLaiHanSPJG)Enum.Parse(typeof(eLaiHanSPJG), spItem.I_SHENPIJG.ToString());
                 * */
            }
            else if (LaiHanLX == eLaiHanLX.销户)
            {
                //获取审批内容
                var spItem = (YS_LH_XIAOHU) GetShenPiNR(lhxx, false);
                //判断是否已存在(之前做过修改则会存在)
                var drc = _YS_LH_XIAOHUBLL
                    .SelectYS_LH_XIAOHUsDynamic(
                        "I_JLZT=0 AND S_LAIHANBH=" + lhxx.S_LAIHANBH + " and I_LIUCHENGBH=" + lhxx.I_LIUCHENGBH, null)
                    .Rows;
                if (drc.Count == 1) spItem.ID = Convert.ToInt32(drc[0]["ID"]);
                //插入数据库
                _YS_LH_XIAOHUBLL.InsertOrUpdate(spItem);
                /*
                //获取审批结果
                spjg = (eLaiHanSPJG)Enum.Parse(typeof(eLaiHanSPJG), spItem.I_SHENPIJG.ToString());
                 **/
            }
            else if (LaiHanLX == eLaiHanLX.销表)
            {
                //获取审批内容
                var spItem = (YS_LH_XIAOBIAO) GetShenPiNR(lhxx, false);
                //判断是否已存在(之前做过修改则会存在)
                var drc = _YS_LH_XIAOBIAOBLL.SelectYS_LH_XIAOBIAOsDynamic(
                    "I_JLZT=0 AND S_LAIHANBH=" + lhxx.S_LAIHANBH + " and I_LIUCHENGBH=" + lhxx.I_LIUCHENGBH, null).Rows;
                if (drc.Count == 1) spItem.ID = Convert.ToInt32(drc[0]["ID"]);
                //插入数据库
                _YS_LH_XIAOBIAOBLL.InsertOrUpdate(spItem);
                /*
                 //获取审批结果
                 spjg = (eLaiHanSPJG)Enum.Parse(typeof(eLaiHanSPJG), spItem.I_SHENPIJG.ToString());
                  **/
            }
            else if (LaiHanLX == eLaiHanLX.退款)
            {
                //获取审批内容
                var spItem = (YS_LH_TUIKUAN) GetShenPiNR(lhxx, false);
                //判断是否已存在(之前做过确认则会存在)
                var drc = _YS_LH_TUIKUANBLL
                    .SelectYS_LH_TUIKUANsDynamic(
                        "I_DANGQIAN=1 AND S_LAIHANBH=" + lhxx.S_LAIHANBH + " and I_LIUCHENGBH=" + lhxx.I_LIUCHENGBH,
                        null).Rows;
                if (drc.Count == 1) spItem.ID = Convert.ToInt32(drc[0]["ID"]);
                //插入数据库
                _YS_LH_TUIKUANBLL.InsertOrUpdate(spItem);
                /*
                //获取审批结果
                spjg = (eLaiHanSPJG)Enum.Parse(typeof(eLaiHanSPJG), spItem.I_SHENPIJG.ToString());
                 **/
            }
            else if (LaiHanLX == eLaiHanLX.分户)
            {
                FenHuXXTZ(lhxx, tijiao, out tijiao);
            }
            else if (LaiHanLX == eLaiHanLX.改户)
            {
                //获取审批内容
                var spItem = (YS_LH_GAIHUXX) GetShenPiNR(lhxx, false);
                //判断是否已存在(之前做过修改则会存在)
                var drc = _YS_LH_GAIHUXXBLL.SelectYS_LH_GAIHUXXesDynamic(
                    "I_JLZT=0 AND S_LAIHANBH=" + lhxx.S_LAIHANBH + " and I_LIUCHENGBH=" + lhxx.I_LIUCHENGBH, null).Rows;
                if (drc.Count == 1) spItem.ID = Convert.ToInt32(drc[0]["ID"]);
                //插入数据库
                _YS_LH_GAIHUXXBLL.InsertOrUpdate(spItem);
                /*
                //获取审批结果
                spjg = (eLaiHanSPJG)Enum.Parse(typeof(eLaiHanSPJG), spItem.I_SHENPIJG.ToString());
                 **/
            }
            else if ((int) LaiHanLX >= 20)
            {
                //获取审批内容
                var spItem = (QS_LH_TONGYONGBZYJ) GetShenPiNR(lhxx, false);
                //判断是否已存在(之前做过修改则会存在)
                var drc = new QS_LH_TONGYONGBZYJProcess().SelectQS_LH_TONGYONGBZYJsDynamic(
                    "I_JLZT=0 AND S_LAIHANBH=" + lhxx.S_LAIHANBH + " and I_LIUCHENGBH=" + lhxx.I_LIUCHENGBH, null).Rows;
                if (drc.Count == 1) spItem.ID = Convert.ToInt32(drc[0]["ID"]);
                //插入数据库
                new QS_LH_TONGYONGBZYJProcess().InsertOrUpdate(spItem);
                /*
                //获取审批结果
                spjg = (eLaiHanSPJG)Enum.Parse(typeof(eLaiHanSPJG), spItem.I_SHENPIJG.ToString());
                 **/
            }
        }

        /// <summary>
        ///     分户调整
        /// </summary>
        /// <param name="lhxx"></param>
        /// <param name="next"></param>
        /// <param name="insertFlow"></param>
        private void FenHuXXTZ(YS_LH_LAIHANXX lhxx, bool next, out bool insertFlow)
        {
            insertFlow = next;
            var BllFenHu = new YS_LH_FENHUXXBLL();
            //获取审批内容
            //YS_LH_FENHUXX spItem = (YS_LH_FENHUXX)this.GetShenPiNR(lhxx, false);
            //判断是否已存在(之前做过修改则会存在)
            var wherecase = "I_JLZT=0 AND S_LAIHANBH='" + lhxx.S_LAIHANBH + "' and S_YONGHUHFATHER='" +
                            lhxx.S_YONGHUBH + "'";
            var drc = new YS_LH_FENHUXXBLL().SelectYS_LH_FENHUXXesDynamic(wherecase, null).Rows;
            if (drc != null && drc.Count > 0)
            {
                var updatecol = " ";
                if (LaiHanLC == eLaiHanLCBH.业务员)
                    updatecol = string.Format("S_YEWUY='{0}',S_SHENPI='{1}' ", txtHuJiSPYJ.Text, 1);//(int) eLaiHanLCBH.业务员
                else if (LaiHanLC == eLaiHanLCBH.主任)
                    updatecol = string.Format("S_ZHUREN='{0}',S_SHENPI='{1}' ", txtHuJiSPYJ.Text,
                        cbTongYi.Checked ? 1 : 0);
                else if (LaiHanLC == eLaiHanLCBH.节水科)
                    updatecol = string.Format("S_JIESHUI='{0}',S_SHENPI='{1}' ", txtHuJiSPYJ.Text,
                        cbTongYi.Checked ? 1 : 0);
                else if (LaiHanLC == eLaiHanLCBH.计财科)
                    updatecol = string.Format("S_JICAI='{0}',S_SHENPI='{1}' ", txtHuJiSPYJ.Text,
                        cbTongYi.Checked ? 1 : 0);
                BllFenHu.UpdateYS_LH_FENHUXXesDynamic(updatecol, wherecase);
                /*
                if (insertFlow && (int)this.LaiHanLC > (int)eLaiHanLCBH.业务员 && (spItem.S_SHENPI == null || Convert.ToInt32(spItem.S_SHENPI) != (int)this.LaiHanLC))
                {
                    int? error = 0;
                    _sphelper.P_YS_LH_BEIFENJHXX(lhxx.S_LAIHANBH, lhxx.S_YONGHUBH, out error);
                    insertFlow = false;
                    lhxx.I_LIUCHENGZT = -3;
                    new YS_LH_LAIHANXXProcess().InsertOrUpdate(lhxx);
                    //更新当前步骤结束时间
                    YS_LH_LAIHANLCJLProcess lcbllt = new YS_LH_LAIHANLCJLProcess();
                    lcbllt.UpdateYS_LH_LAIHANLCJLsDynamic("D_ENDDATE=to_date('" + DateTime.Now.ToString() + "','yyyy-MM-dd HH24:mi:ss')", "I_JLZT=0 AND S_LAIHANBH=" + lhxx.S_LAIHANBH + " AND I_LIUCHENGBH=" + lhxx.I_LIUCHENGBH);
                }
                 * */
            }
        }

        #endregion
    }
}